<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>点击切换内容颜色</title>
  <style>
    .actived {
      color: pink;
    }

    [v-cloak] {
      display: none;
    }
  </style>
</head>

<body>
  <div id="app">
    <ul v-cloak>
      <!-- 这里使用方法更改DOM索引为当前选中索引，妙呀 -->
      <li :class="{actived: currentIndex == index}" v-for="(item,index) in message" @click="changeIndex(index)">
        {{item}}</li>
    </ul>
  </div>
  <script src="../../vue.js"></script>
  <script>
    new Vue({
      el: '#app',
      data: {
        message: ['绿皮书', '少年派的奇幻漂流', '饮食男女'],
        currentIndex: 0
      },
      methods: {
        changeIndex(index) {
          this.currentIndex = index
        }
      }
    })
  </script>
</body>

</html>